<template>
	<view>

	</view>
</template>
<script lang="ts">
	// @ts-nocheck
	import Vue from 'vue';
	import { getAliUserId } from "../../api/common/login";

	export default Vue.extend({
		async onShow() {
			await this.login()
		},
		methods: {
			async login() {
				console.log('调用登陆token')
				let loginRes;
				// loginRes = await uni.login({ provider: 'weixin' });
				loginRes=await my.getAuthCode({scope:'auth_base'})
				console.log(loginRes.authCodes)
				// return
				// if (loginRes.errMsg !== 'login:ok') {
				// 	console.log("静默登陆失败：", loginRes)
				// }

				console.log("静默登陆获取code：", loginRes.authCode) //微信code，静默登录
				const { code, data, msg } = await getAliUserId(loginRes.authCode)
				if (code !== 1) {
					console.log('登陆失败：', data, msg)
				} else {
					console.log('登陆成功：', data)
					// uni.setStorageSync('token', data)
					// uni.switchTab({
					// 	url: '/pages/index/index'
					// })
				}
			}
		}
	})
</script>